//
//  Searches.m
//  SolarSeek
//
//  Created by Erick Fejta on 05/02/18.
//  Copyright 2005 Erick Fejta. All rights reserved.
//

#import "Searches.h"


@implementation Search

- (id)init {
	[self release];
	return nil;
}

- (id)initWithQuery:(NSString *)q {
	if(self = [super init]) {
		query = [q copy];
		sharesTree = [[ShareTree alloc] initWithPathData:[NSData data]];
	}
	return self;
}

- (id)initWithCoder:(NSCoder *)decoder {
	query = [[decoder decodeObject] retain];
	//fejta: TODO: change for sharetree.
	sharesTree = [[ShareTree alloc] initWithPathData:[NSData data]];
	return self;
}

- (void)encodeWithCoder:(NSCoder *)coder {
	[coder encodeObject:query];
	//fejta: TODO: encode shrae tree.
}


- (void)dealloc {
	[query release];
	[sharesTree release];
	[super dealloc];
}

- (NSString *)query { return query; }

- (ShareTree *)sharesTreeRoot { return sharesTree; }

- (NSString *)description { 
	return [NSString stringWithFormat:@"Search for %@. %d results found.",query,[[self results] count]]; 
}
@end
